package com.design.adapter;

/**
 * @author leali
 * @title: OperationAdapter
 * @projectName design
 * @description: 操作适配器：适配器
 * @date 2022/1/2 22:14
 */
public class OperationAdapter implements ScoreOperation {
    /**
     * 定义适配者QuickSort对象
     */
    private final QuickSort sortObj;
    /**
     * 定义适配者BinarySearch对象
     */
    private final BinarySearch searchObj;

    public OperationAdapter() {
        sortObj = new QuickSort();
        searchObj = new BinarySearch();
    }

    @Override
    public int[] sort(int[] array) {
        return sortObj.quickSort(array);
    }

    @Override
    public int search(int[] array, int key) {
        return searchObj.binarySearch(array, key);
    }
}
